package com.financing.wap.web.controller.api;

import java.util.HashMap;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.financing.wap.common.ResultMap;
import com.financing.wap.common.ResultMap.STATUS;
import com.financing.wap.dto.FpProductDeepAnalyticsDTO;
import com.financing.wap.service.IProductDeepAnalyticsService;
import com.financing.wap.util.StringUtil;
import com.financing.wap.web.controller.BaseController;

/**
 *  产品深度分析 控制器
 * @author lisu
 *  lisu
 */
@Controller("apiProductDeepAnalyticsController")
@RequestMapping("/api/product")
public class ProductDeepAnalyticsController extends BaseController {

	Logger logger = Logger.getLogger(getClass());

	@Autowired
	private IProductDeepAnalyticsService productDeepAnalyticsService;
	/**
	 * 展示产品 深度分析
	 * @return
	 */
	@SuppressWarnings({ "rawtypes", "unchecked" })
	@RequestMapping("/deepAnalyticsView")
	@ResponseBody
	public ResultMap viewProduct(String code,String preview){

		ResultMap result = new ResultMap();
		try {
			Map map = new HashMap();
			map.put("productCode",code);
			if(StringUtil.isNullOrEmptyStr(preview)){
				map.put("fpProductStatus","'1'");
			}else if(preview.equals("true")){
				map.put("fpProductStatus","'1','2'");
			}
			FpProductDeepAnalyticsDTO dto = productDeepAnalyticsService.getFpProductDeepAnalyticsView(map);
			
				result.setStatus(STATUS.SUCCESS);
				result.setStatusCode(ResultMap.STATUS_CODE_SUCCESS);
				result.setAttribute("dto", dto);
				return result;
		}catch(Exception e) {
			logger.error("==>warn messang:",e);
			result.setStatus(STATUS.WARN);
			result.setStatusCode(ResultMap.STATUS_CODE_SYS_EXCEPTION);
			return result;
		}
	}
}
